home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / g_man / cat3 / standard / blendfunction.z / blendfunction
Encoding:
Text File  |  1998-10-20  |  13.6 KB  |  260 lines

  1.  
  2.  
  3.  
  4. bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))                                            bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn - computes a blended color value for a pixel
  10.  
  11. CCCC SSSSPPPPEEEECCCCIIIIFFFFIIIICCCCAAAATTTTIIIIOOOONNNN
  12.      vvvvooooiiiidddd bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((lllloooonnnngggg ssssffffaaaaccccttttrrrr,,,, lllloooonnnngggg ddddffffaaaaccccttttrrrr))))
  13.  
  14. PPPPAAAARRRRAAAAMMMMEEEETTTTEEEERRRRSSSS
  15.      _s_f_a_c_t_r   is a symbolic constant taken from the list below.  It identifies
  16.               the blending factor by which to scale contribution from source
  17.               pixel RGBA (red, green, blue, alpha) values.
  18.  
  19.               BBBBFFFF____ZZZZEEEERRRROOOO        0
  20.               BBBBFFFF____OOOONNNNEEEE         1
  21.               BBBBFFFF____DDDDCCCC          (destination RGBA)/255
  22.               BBBBFFFF____MMMMDDDDCCCC         1 - (destination RGBA)/255
  23.               BBBBFFFF____SSSSAAAA          (source alpha)/255
  24.               BBBBFFFF____MMMMSSSSAAAA         1 - (source alpha)/255
  25.               BBBBFFFF____DDDDAAAA          (destination alpha)/255
  26.               BBBBFFFF____MMMMDDDDAAAA         1 - (destination alpha)/255
  27.               BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA  _m_i_n(BBBBFFFF____SSSSAAAA,,,, BBBBFFFF____MMMMDDDDAAAA)
  28.               BBBBFFFF____CCCCCCCC          (constant RGBA)/255
  29.               BBBBFFFF____MMMMCCCCCCCC         1 - (constant RGBA)/255
  30.               BBBBFFFF____CCCCAAAA          (constant alpha)/255
  31.               BBBBFFFF____MMMMCCCCAAAA         1 - (constant alpha)/255
  32.               BBBBFFFF____MMMMIIIINNNN         _m_i_n(1, destination RGBA/source RGBA)
  33.               BBBBFFFF____MMMMAAAAXXXX         _m_a_x(1, destination RGBA/source RGBA)
  34.  
  35.      _d_f_a_c_t_r   is a symbolic constant taken from the list below.  It identifies
  36.               the blending factor by which to scale contribution from
  37.               destination pixel RGBA values.
  38.  
  39.               BBBBFFFF____ZZZZEEEERRRROOOO        0
  40.               BBBBFFFF____OOOONNNNEEEE         1
  41.               BBBBFFFF____SSSSCCCC          (source RGBA)/255
  42.               BBBBFFFF____MMMMSSSSCCCC         1 - (source RGBA)/255
  43.               BBBBFFFF____SSSSAAAA          (source alpha)/255
  44.               BBBBFFFF____MMMMSSSSAAAA         1 - (source alpha)/255
  45.               BBBBFFFF____DDDDAAAA          (destination alpha)/255
  46.               BBBBFFFF____MMMMDDDDAAAA         1 - (destination alpha)/255
  47.               BBBBFFFF____CCCCCCCC          (constant RGBA)/255
  48.               BBBBFFFF____MMMMCCCCCCCC         1 - (constant RGBA)/255
  49.               BBBBFFFF____CCCCAAAA          (constant alpha)/255
  50.               BBBBFFFF____MMMMCCCCAAAA         1 - (constant alpha)/255
  51.  
  52.      A blending factor is obtained by evaluating a mathematical expression
  53.      over a source RGBA value, a destination RGBA value and a constant RGBA
  54.      value.  The latter is provided with bbbblllleeeennnnddddccccoooolllloooorrrr.
  55.  
  56.      Blending factors, except for BBBBFFFF____MMMMIIIINNNN and BBBBFFFF____MMMMAAAAXXXX, use RGBA values converted
  57.      to fractions of the maximum value 255.  To improve performance, these
  58.      conversion calculations are approximate.  However, 0 converts exactly to
  59.      0.0, and 255 converts exactly to 1.0.
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))                                            bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))
  71.  
  72.  
  73.  
  74. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  75.      In RGB mode, the system draws pixels using a function that blends the
  76.      incoming (source) RGBA values with the RGBA values that are already in
  77.      the framebuffer (the destination values).  Most often, blending is
  78.      simple: the source RGBA values replace the destination RGBA values of the
  79.      pixel.
  80.  
  81.      In some cases, however, simple replacement of framebuffer values is not
  82.      appropriate.  Two such cases are transparency and antialiasing.  To be
  83.      blended properly, transparent objects must be rendered back-to-front
  84.      (i.e. drawn in order from the farthest object to the nearest object) with
  85.      a blend function of ((((BBBBFFFF____SSSSAAAA,,,, BBBBFFFF____MMMMSSSSAAAA)))).  As can be seen from the equations
  86.      below, this function scales the incoming color components by the incoming
  87.      alpha value, and scales the framebuffer contents by one minus the
  88.      incoming alpha value.  Thus incoming (source) alpha is correctly thought
  89.      of as a material opacity, ranging from 1.0 (completely opaque) to 0.0
  90.      (completely transparent).  Note that this transparency calculation does
  91.      not require the presence of alpha bitplanes in the framebuffer.
  92.  
  93.      Suggestions for appropriate blend functions for antialiasing are given on
  94.      the ppppnnnnttttssssmmmmooooooootttthhhh and lllliiiinnnneeeessssmmmmooooooootttthhhh manual pages.  Other less obvious
  95.      applications are also possible.  For example, if the red component in the
  96.      framebuffer is first cleared to all zeros, and then each primitive is
  97.      drawn with red set to 1 and a blend function of ((((BBBBFFFF____OOOONNNNEEEE,,,, BBBBFFFF____OOOONNNNEEEE)))), the red
  98.      component of each pixel in the framebuffer will contain the count of the
  99.      number of times that pixel was drawn.
  100.  
  101.      To determine the blended RGBA values of a pixel when drawing in RGB mode,
  102.      the system uses the following functions:
  103.  
  104.           Rdestination = _m_i_n (255, ((Rsource * _s_f_a_c_t_r) + (Rdestination * _d_f_a_c_t_r)))
  105.  
  106.  
  107.           Gdestination = _m_i_n (255, ((Gsource * _s_f_a_c_t_r) + (Gdestination * _d_f_a_c_t_r)))
  108.  
  109.  
  110.           Bdestination = _m_i_n (255, ((Bsource * _s_f_a_c_t_r) + (Bdestination * _d_f_a_c_t_r)))
  111.  
  112.  
  113.           Adestination = _m_i_n (255, ((Asource * _s_f_a_c_t_r) + (Adestination * _d_f_a_c_t_r)))
  114.  
  115.  
  116.      When the blend function is set to ((((BBBBFFFF____OOOONNNNEEEE,,,, BBBBFFFF____ZZZZEEEERRRROOOO)))), the default values,
  117.      the equations reduce to simple replacement:
  118.           Rdestination = Rsource
  119.  
  120.           Gdestination = Gsource
  121.  
  122.           Bdestination = Bsource
  123.  
  124.  
  125.                                                                         PPPPaaaaggggeeee 2222
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132. bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))                                            bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))
  133.  
  134.  
  135.  
  136.           Adestination = Asource
  137.      Fill rate may be increased substantially when blending is disabled in
  138.      this manner.
  139.  
  140.      Polygon antialiasing (see ppppoooollllyyyyssssmmmmooooooootttthhhh) is sometimes optimized when the
  141.      blendfunction (BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA,,,, BBBBFFFF____OOOONNNNEEEE)))) is used.  Source factor
  142.      BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA, which should be used only with destination factor BBBBFFFF____OOOONNNNEEEE,
  143.      has the side effect of slightly modifying the blending arithmetic:
  144.  
  145.           Rdestination = _m_i_n (255, ((Rsource * _s_f_a_c_t_r) + Rdestination))
  146.  
  147.  
  148.           Gdestination = _m_i_n (255, ((Gsource * _s_f_a_c_t_r) + Gdestination))
  149.  
  150.  
  151.           Bdestination = _m_i_n (255, ((Bsource * _s_f_a_c_t_r) + Bdestination))
  152.  
  153.  
  154.           Adestination = _s_f_a_c_t_r + Adestination
  155.      This special blend function accumulates pixel contributions until the
  156.      pixel is fully specified, then allows no further changes.  Destination
  157.      alpha bitplanes, which must be present for this blend function to operate
  158.      correctly, store the accumulated coverage.
  159.  
  160.      In order to store the smallest or the largest RGBA value among the source
  161.      RGBA and destination RGBA, simply use
  162.  
  163.           blendfunction(BF_MIN, BF_ZERO);
  164.  
  165.      or
  166.  
  167.           blendfunction(BF_MAX, BF_ZERO);
  168.  
  169.      respectively.
  170.  
  171.      Blending is available with or without z-buffer mode.  When blendfunction
  172.      is set to any value other than ((((BBBBFFFF____OOOONNNNEEEE,,,, BBBBFFFF____ZZZZEEEERRRROOOO)))), logicop is forced to
  173.      LLLLOOOO____SSSSRRRRCCCC.
  174.  
  175. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  176.      cpack, linesmooth, logicop, pntsmooth, polysmooth, blendcolor
  177.  
  178. NNNNOOOOTTTTEEEESSSS
  179.      Blending factors BBBBFFFF____DDDDAAAA, BBBBFFFF____MMMMDDDDAAAA, and BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA are not supported on
  180.      machines without alpha bitplanes.
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.                                                                         PPPPaaaaggggeeee 3333
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194. bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))                                            bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn((((3333GGGG))))
  195.  
  196.  
  197.  
  198.      IRIS-4D G, GT, and GTX models, the Personal Iris, Indigo Entry, XS, XS24,
  199.      XZ, Elan and Extreme systems do not support blend factor BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA.
  200.  
  201.      IRIS-4D G, GT, GTX, VGX, and VGXT models, the Personal Iris, Indigo
  202.      Entry, Indy, XL, XS, XS24, and Elan systems do not support blend factors
  203.      BBBBFFFF____CCCCCCCC, BBBBFFFF____MMMMCCCCCCCC, BBBBFFFF____CCCCAAAA, BBBBFFFF____MMMMCCCCAAAA, BBBBFFFF____MMMMIIIINNNN and BBBBFFFF____MMMMAAAAXXXX.
  204.  
  205.      IRIS-4D B and G models and the Personal Iris do not support this function
  206.      at all.  Use ggggeeeettttggggddddeeeesssscccc((((GGGGDDDD____BBBBLLLLEEEENNNNDDDD)))) to determine whether blending hardware is
  207.      available.
  208.  
  209. BBBBUUUUGGGGSSSS
  210.      Blending works properly only in RGB mode.  In color map mode, the results
  211.      are unpredictable.
  212.  
  213.      On IRIS-4D G, GT, GTX, VGX, and VGXT models, the Personal Iris, Indigo
  214.      Entry, Indy, XL, XS, XS24, and Elan systems when multiple destination
  215.      buffers are specified (using ffffrrrroooonnnnttttbbbbuuuuffffffffeeeerrrr,,,, bbbbaaaacccckkkkbbbbuuuuffffffffeeeerrrr,,,, and zzzzddddrrrraaaawwww ) only a
  216.      single location can be read and used as the _d_e_s_t_i_n_a_t_i_o_n value on the
  217.      right side of the above equations.  As a result, the _d_e_s_t_i_n_a_t_i_o_n values
  218.      on the left and the right of the equations may not be taken from the same
  219.      framebuffer locations.  By default, the destination RGBA values are read
  220.      from the front buffer in single buffer mode and from the back buffer in
  221.      double buffer mode.  If the front buffer is not enabled in single buffer
  222.      mode, the RGBA values are taken from the z-buffer.  If the back buffer is
  223.      not enabled in double buffer mode, the RGBA values are taken from the
  224.      front buffer (if possible) or from the z-buffer.
  225.  
  226.      On some IRIS-4D GT and GTX models, while copying rectangles with blending
  227.      active, rrrreeeeaaaaddddssssoooouuuurrrrcccceeee also specifies the bank from which _d_e_s_t_i_n_a_t_i_o_n color
  228.      and alpha are read (overriding the bbbblllleeeennnnddddffffuuuunnnnccccttttiiiioooonnnn setting).
  229.  
  230.      IRIS-4D VGX models do not clamp color values generated by the special
  231.      blending function BBBBFFFF____MMMMIIIINNNN____SSSSAAAA____MMMMDDDDAAAA,,,,BBBBFFFF____OOOONNNNEEEE to 255.  Instead, color values are
  232.      allowed to wrap.
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.                                                                         PPPPaaaaggggeeee 4444
  254.  
  255.  
  256.  
  257.